package com.itheima.d6_singleInstance;

/**
 * 饿汉单例：先赋值
 */
public class Wife {
    private String name;

    //2. 提供一个当前类型的类变量
    private static Wife wife = new Wife();

    //1. 私有化构造器
    private Wife() {
        name = "迪丽热巴";
    }

    //3. 提供一个类方法返回单例对象
    public static Wife getInstance() {
        return wife;
    }

    public void show() {
        System.out.println("我老婆是" + name);
    }

}
